home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / Font.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  29.6 KB  |  713 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Font.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    1.0.13+>    11/19/93    NAGA        modify TCS format
  19. #    <1.0.13>     9/22/93    KTA        Removed gHandleTextEntry as no one was using it.
  20. #    <1.0.12>     9/13/93    KTA        Updated TestLevel specification.
  21. #    <1.0.11>     8/30/93    KTA        Updated task headers and parameters.
  22. #    <1.0.10>     8/25/93    KTA        Added support for parity checking the TCS stack.
  23. #     <1.0.9>     7/30/93    KTA        Added checks in SetStyle(), SetSize(), SetFont() to see if
  24. #                                    menuItem is enabled.  If not TCSReturn :=  -1.
  25. #     <1.0.8>     7/23/93    KTA        SetStyle() - gCurrStyleMenu - Help insure that it is initilized
  26. #                                    correctly.
  27. #     <1.0.7>     7/14/93    KTA        International Support: See InitFonts(),
  28. #                                    ReportSelectedMenuItems(), SetFont(), SetStyle(), SetSize(). Now
  29. #                                    depends on Output.Lib.
  30. #     <1.0.5>      6/8/93    NAGA        unmark tasks that are not to be published
  31. #    <1.0.3>         5/21/93    NAGA        Adding header and porting old files to follow new standards
  32. #
  33. # ****************************************************************************
  34. #
  35.  
  36. ########################################################################
  37. #                            External libraries 
  38. #=======================================================================
  39. Libraries "TCS.Lib","UserInterface.Lib", "OutPut.Lib";
  40.  
  41.  
  42. #########################################################################
  43. #                                Font.Lib
  44. #========================================================================
  45. # Description:    This module contains VU code for exercising fonts, styles, and
  46. #                sizes.  There are three modes of font testing currently defined.
  47. #                These can be executed by calling DoText with certain globals set 
  48. #                appropriately. The following section details the proper global
  49. #                settings to execute the various test methods.
  50. #                All of the methods are based on the execution of a FontRecord which
  51. #                consists of three elements {"FontName", "SizeName", {StyleList}};
  52. #                For example: ourFontRecord := {'Geneva','12',{'Bold','Italic'}};
  53. #                
  54. #
  55. #                                        ---- globals ----
  56. #                In order to execute any of the font testing methods there are a  
  57. #                series of globals that must be defined in the Task-InitFonts();
  58. #
  59. #                All font characteristics are generated from the predefined global
  60. #                font lists: gFontList, gFontSizeList, gFontStyleList. 
  61. #                Define these lists with appropriate Fonts, Sizes and Styles.
  62. #                These are the first block of globals in InitFontglobals();
  63. #                
  64. #                DO NOT define the second block of globals (gCurrFontMenu, gCurrSizeMenu,
  65. #                gCurrStyleMenu). These globals will be automatically defined. They 
  66. #                store the titles to the menus which contain the font characteristic 
  67. #                menu items.
  68. #                
  69. #                The global gPlainStyle should be defined as the menu item which clears
  70. #                all font styles.
  71. #
  72. #                The global gNextLineMethod should be defined as the appropriate method
  73. #                which a particular application requires to be prepared to enter the 
  74. #                next line of text.
  75. #                
  76. #                The global gNextLineClearsFontSettings should be set to a 1 if the 
  77. #                method of moving to the next line of text clears all the font settings. 
  78. #                It should be set to 0 if moving to the next line retains the font 
  79. #                settings - ( important if the test method is kWaterFall - see below)
  80. #                
  81. #
  82. #                                    ---- TEST METHODS ----
  83. #            • Generate Random FontRecords -
  84. #                1) Set gFontLevel to equal kRandomText. (i.e. global gFontLevel := kRandomText;)
  85. #                2) Set NumTimes input parameter to equal the number of random text records. 
  86. #                    DoText(3,5); # For 5 random text records
  87. #                3) Call DoText();
  88. #
  89. #                - The FontRecord generated will include a random Font, a random size,
  90. #                    and a random number of random styles.
  91. #
  92. #            • QuickLook method -
  93. #                1) Set gFontLevel to equal kQLFontTest. (i.e. global gFontLevel := kQLFontTest;)
  94. #                2) Call DoText();
  95. #
  96. #                - This will generated 1 FontRecord for each font with a random size and
  97. #                    a random combination of styles.
  98. #
  99. #            • WaterFall method -
  100. #                1) Set gFontLevel to equal kWaterFall. (i.e. global gFontLevel := kWaterFall;)
  101. #                2) Be sure the global gNextLineClearsFontSettings is set correctly (See above)
  102. #                3) Call DoText();
  103. #
  104. #                - This will generated 1 FontRecord for each font with every size and combination 
  105. #                    of styles.
  106. #                    For example the first record may be {"Helvetica", '12', {'Bold'}}; and the 
  107. #                    second record might be {"Helvetica", '12', {'Bold', 'italic'}}
  108. #
  109. #     Copyright Apple Computer, Inc. 1985-1991
  110. #    All rights reserved
  111. #
  112. #========================================================================
  113. # History:
  114. #
  115. #########################################################################
  116.  
  117.     ##### Accessors ####
  118. task ReplaceFont(pCurrentFont,pCurrentFontRecord) begin return(Replace(pCurrentFont,1,pCurrentFontRecord)); end;
  119. task ReplaceFontSize(pCurrentSize,pCurrentFontRecord) begin return(Replace(pCurrentSize,2,pCurrentFontRecord)); end;
  120. task ReplaceFontStyle(pStyleList,pCurrentFontRecord) begin return(Replace(pStyleList,3,pCurrentFontRecord)); end;
  121.  
  122.  
  123. #########################################################################
  124. #                        InitFonts()
  125. #========================================================================
  126. # Author:        KTA
  127. # Description:    Initializes the font globals. 
  128. # Parameters:    None
  129. # Returns:        Nada
  130. # Examples:        InitFonts();
  131. # Assumptions:    
  132. #========================================================================
  133. # History:
  134. # KTA    7/8/93    Move gFontList, gFontStyleList, gFontSizeList to Globals.Lib (intl)
  135. #########################################################################
  136. TASK InitFonts()
  137. begin
  138.     #===== Task references =======
  139.     global gSetFont              := Task SetFont;        # Requires VU 2.0
  140.     global gSetSize              := Task SetSize;        # Requires VU 2.0
  141.     global gSetStyle             := Task SetStyle;        # Requires VU 2.0
  142.     global gNextLine             := Task NextLine;        # Requires VU 2.0
  143.     
  144.     global gFontObject            := 0;        # Object Number in a given suite
  145.  
  146.     #======= font characteristic lists  >> Moved to Globals.Lib =======
  147.     
  148.     #####################################################################
  149.     #### Do not change the values below!!! 
  150.     #### The following Globals are default values and if an application needs
  151.     #### to override them it should be done from within the script.  
  152.     #####################################################################
  153.         ### Name of the Plain (style) menu item  ####
  154.     global gPlainStyle := "Plain";            # Plain-Style menu item
  155.  
  156.         ### How to get to the next line
  157.     global gNextLineMethod := 1;            
  158.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  159.     
  160.         ### Does moving to the next line clear all font info
  161.     global gNextLineClearsFontSettings := 1;                        
  162. end;
  163. #########################################################################
  164. #                        SetFont(pMyFont, pObjectNumber)
  165. #========================================================================
  166. # Author:        KTA
  167. # Description:    Selects <pMyFont> menuitem to set the current font.  
  168. # Parameters:    pMyFont - Name of the font.
  169. #                pObjectNumber - Integer used to track all elements that make up 
  170. #                                an Font record - TCS related.
  171. # Returns:        returns what SelectMenuItem returns 
  172. #                    0 - failure
  173. #                    String - success
  174. # Examples:        SetFont('Geneva');
  175. # Assumptions:    That InitFonts() has been called thus global gCurrFontMenu
  176. #                is set to the name of the menus which contain <pMyFont>
  177. #========================================================================
  178. # History:
  179. # KTA 7/8/93    gCurrFontMenu update for intl
  180. # KTA 7/30/93    TCSReturn -1 if menuItem is not enabled
  181. # KTA 8/24/93    TCS stack parity check
  182. #########################################################################
  183. TASK SetFont(pMyFont := '', pObjectNumber := 'NA') 
  184. begin
  185.     failStr := "";
  186.     returnVal := 0;
  187.     if not(global gCurrFontMenu)                # Menu(s) which contain the menu item
  188.     begin
  189.         gCurrFontMenu := FindMenu(global gFontList[1]);    
  190.         if not(gCurrFontMenu)                # Menu(s) which contain the menu item
  191.             gCurrFontMenu := FindMenu("Chicago");    
  192.     end;
  193.         
  194.     if (gCurrFontMenu)
  195.     begin
  196.         TCSStart({ 1, global kTCSetFont},"SetFont");        # Start TCS
  197.         returnVal := SelectMenuItem(pMyFont,gCurrFontMenu[1],gCurrFontMenu[2]);    # Select the font from the Font menu
  198.         if (returnVal)
  199.             myReturn := 1;
  200.         else    # No returnVal - SelectMenuItem failed
  201.         begin
  202.             if (gCurrFontMenu[2])
  203.                 theMenuItem :=  match[menuItem t:pMyFont m:[menuItem t:gCurrFontMenu[1] m:[menu t:gCurrFontMenu[2]]]]!;
  204.             else 
  205.                 theMenuItem :=  match[menuItem t:pMyFont m:[menu t:gCurrFontMenu[1]]]!;
  206.             if(theMenuItem)
  207.             begin    
  208.                 if (theMenuItem.e)
  209.                 begin
  210.                     myReturn := -1;        # disabled menuItem - expected that can't be selected
  211.                     failStr := "MenuItem is disabled so it couldn't be selected";
  212.                 end;
  213.             end;
  214.             else
  215.             begin
  216.                 myReturn := returnVal;
  217.                 failStr := "Couldn't select menuItem, it is not present.";
  218.             end;
  219.         end;
  220.  
  221.         TCSEnd( {1, global kTCSetFont}, myReturn,failStr,pObjectNumber,pMyFont);
  222.     end;
  223.     else
  224.         LogStr("Sorry, can't locate the font menu.  Is the gFontList set up correctly?");
  225.     return(returnVal);
  226. end; # SetFont()
  227.  
  228. #########################################################################
  229. #                        SetStyle(pMyStyle, pObjectNumber)
  230. #========================================================================
  231. # Author:        KTA
  232. # Description:    Sets the currently selected font style to <pMyStyle> 
  233. # Parameters:    pMyStyle - Name of the Style.
  234. #                pObjectNumber - Integer used to track all elements that make up 
  235. #                                an Font record - TCS related.
  236. # Returns:        returns what SelectMenuItem returns 
  237. #                    0 - failure
  238. #                    String - success
  239. # Examples:        SetStyle('Bold');
  240. # Assumptions:    That InitFonts() has been called thus global gCurrStyleMenu
  241. #                is set to the name of the menus which contain <pMyStyle>
  242. #========================================================================
  243. # History:
  244. # KTA 7/8/93    gCurrStyleMenu update for intl
  245. # KTA 7/23/93    gCurrStyleMenu - Help insure that it is initilized correctly
  246. # KTA 7/30/93    TCSReturn -1 if menuItem is not enabled
  247. # KTA 8/24/93    TCS stack parity check
  248. #########################################################################
  249. TASK SetStyle(pMyStyle := '', pObjectNumber := 'NA') 
  250. begin
  251.     failStr := "";
  252.     returnVal := 0;
  253.     if not(global gCurrStyleMenu)                # Menu(s) which contain the menu item
  254.     begin
  255.         if (global gFontStyleList[1])
  256.             gCurrStyleMenu := FindMenu(global gFontStyleList[1]);    
  257.         if not(gCurrStyleMenu)                # Help insure that it is initilized correctly
  258.             gCurrStyleMenu := FindMenu('Bold');
  259.     end;
  260.     if (gCurrStyleMenu) 
  261.     begin
  262.         TCSStart({ 3, global kTCSetFont},"SetStyle");        # Start TCS
  263.         returnVal := SelectMenuItem(pMyStyle,gCurrStyleMenu[1],gCurrStyleMenu[2]);    # Select the font from the Font menu
  264.         if (returnVal)
  265.             myReturn := 1;
  266.         else    # No returnVal - SelectMenuItem failed
  267.         begin
  268.             if (gCurrStyleMenu[2])
  269.                 theMenuItem :=  match[menuItem t:pMyStyle m:[menuItem t:gCurrStyleMenu[1] m:[menu t:gCurrStyleMenu[2]]]]!;
  270.             else 
  271.                 theMenuItem :=  match[menuItem t:pMyStyle m:[menu t:gCurrStyleMenu[1]]]!;
  272.             if(theMenuItem)
  273.             begin    
  274.                 if (theMenuItem.e)
  275.                 begin
  276.                     myReturn := -1;        # disabled menuItem - expected that can't be selected
  277.                     failStr := "MenuItem is disabled so it couldn't be selected";
  278.                 end;
  279.             end;
  280.             else
  281.             begin
  282.                 myReturn := returnVal;
  283.                 failStr := "Couldn't select menuItem, it is not present.";
  284.             end;
  285.         end;
  286.         
  287.         TCSEnd({ 3, global kTCSetFont }, myReturn,failStr,pObjectNumber,pMyStyle);
  288.     end;
  289.     else
  290.         LogStr("Sorry, can't locate the style menu.  Is the gFontStyleList set up correctly?");
  291.     return(returnVal);
  292. end; # SetStyle()
  293.  
  294. #########################################################################
  295. #                        SetSize(pMySize, pObjectNumber)
  296. #========================================================================
  297. # Author:        KTA
  298. # Description:    Sets the currently selected font size to <pMySize> 
  299. # Parameters:    pMySize - Name of the size.
  300. #                pObjectNumber - Integer used to track all elements that make up 
  301. #                                an Font record - TCS related.
  302. # Returns:        returns what SelectMenuItem returns 
  303. #                    0 - failure
  304. #                    String - success
  305. # Examples:        SetSize('10');
  306. # Assumptions:    That InitFonts() has been called thus global gCurrSizeMenu
  307. #                is set to the name of the menus which contain <pMySize>
  308. #========================================================================
  309. # History:
  310. # KTA 7/8/93    gCurrSizeMenu update for intl
  311. # KTA 7/30/93    TCSReturn -1 if menuItem is not enabled
  312. # KTA 8/24/93    TCS stack parity check
  313. #########################################################################
  314. TASK SetSize(pMySize := '', pObjectNumber := 'NA') 
  315. begin
  316.     failStr := '';
  317.     returnVal :=0;
  318.     if not(global gCurrSizeMenu)                # Menu(s) which contain the menu item
  319.         gCurrSizeMenu := FindMenu(global gFontSizeList[1]);         
  320.     if (gCurrSizeMenu) 
  321.     begin
  322.         TCSStart({ 2, global kTCSetFont },"SetSize");        # Start TCS
  323.         returnVal := SelectMenuItem(pMySize,gCurrSizeMenu[1],gCurrSizeMenu[2]);    # Select the font from the Font menu
  324.         if (returnVal)
  325.             myReturn := 1;
  326.         else    # No returnVal - SelectMenuItem failed
  327.         begin
  328.             if (gCurrSizeMenu[2])
  329.                 theMenuItem :=  match[menuItem t:pMySize m:[menuItem t:gCurrSizeMenu[1] m:[menu t:gCurrSizeMenu[2]]]]!;
  330.             else 
  331.                 theMenuItem :=  match[menuItem t:pMySize m:[menu t:gCurrSizeMenu[1]]]!;
  332.             if(theMenuItem)
  333.             begin    
  334.                 if (theMenuItem.e)
  335.                 begin
  336.                     myReturn := -1;        # disabled menuItem - expected that can't be selected
  337.                     failStr := "MenuItem is disabled so it couldn't be selected";
  338.                 end;
  339.             end;
  340.             else
  341.             begin
  342.                 myReturn := returnVal;
  343.                 failStr := "Couldn't select menuItem, it is not present.";
  344.             end;
  345.         end;
  346.             
  347.         TCSEnd({ 2, global kTCSetFont }, myReturn,failStr,pObjectNumber,pMySize);
  348.     end;
  349.     else
  350.         LogStr("Sorry, can't locate the size menu.  Is the gFontSizeList set up correctly?");
  351.     return(returnVal);
  352. end; # SetSize()
  353.  
  354. #########################################################################
  355. #                        NextLine()
  356. #========================================================================
  357. # Author:        KTA
  358. # Description:    Prepares application to accept the next line of text
  359. # Parameters:    None
  360. #                gNextLineMethod = 
  361. #                    1 - ReturnKey
  362. #                    2 - Enter Key
  363. #                    3 - Down Arrow Key
  364. #                    4 - Tab Key
  365. #                    {<Optional Specifier>} - if no specifier will select the 
  366. #                        first document window with close and grow box.
  367. # Returns:        Nada
  368. # Examples:        NextLine();
  369. # Assumptions:    global gNextLineMethod is set to the correct method required for 
  370. #                preparing the application to accept the next line of text.
  371. #========================================================================
  372. # History:
  373. #
  374. #########################################################################
  375. TASK NextLine() begin
  376.     global gNextLineMethod;
  377.     ### For more than 1 line of text a new line must be selected
  378.     if (TypeOf(gNextLineMethod) = 'integer')
  379.     begin
  380.         ### Cases of Keystrokes to move to next line
  381.         if (gNextLineMethod = 1)                            # 1 - ReturnKey
  382.             SpecialKey(returnKey,"Return Key");
  383.         else if (gNextLineMethod = 2)                        # 2 - EnterKey
  384.             SpecialKey(enterKey,"Enter Key");
  385.         else if (gNextLineMethod = 3)                        # 3 - DownArrow Key
  386.             SpecialKey(downarrowKey,"Down Arrow Key");
  387.         else if (gNextLineMethod = 4)                        # 4 - TabKey
  388.             SpecialKey(tabKey,"Tab Key");
  389.     end;
  390.     else 
  391.     begin
  392.         #you want random move and click
  393.         if(gNextLineMethod = {})                            # {} - Move/Click
  394.             whichWindow := 0;
  395.         else
  396.             whichWindow := gNextLineMethod[1];                # {} - Move relative to the window <gNextLineMethod[1]> then Click
  397.         
  398.         MoveRelativeToWindow('random','random',whichWindow,2,{60,60,30,30});        #move pointer to a random
  399.     end;
  400. end; # NextLine()
  401.  
  402.  
  403. #########################################################################
  404. #                        RandomFontRecords(pCurrentFontRecord)
  405. #========================================================================
  406. # Author:        KTA
  407. # Description:    Creates random font records based on the globals: gFontList,
  408. #                gFontSizeList, gFontStyleList. 
  409. # Parameters:    pCurrentFontRecord - The script writer can define a partial record
  410. #                                    and a complete record will be returned.
  411. # Returns:        pCurrentFontRecord := {FontName, SizeName,{StyleName1, StyleName2}};
  412. # Examples:        RandomFontRecords(); may return - {'Geneva','12'{'Bold','Italic'}}
  413. # Assumptions:    
  414. #========================================================================
  415. # History:
  416. #
  417. #########################################################################
  418. TASK RandomFontRecords(pCurrentFontRecord := {"","",""})
  419. begin
  420.     global gFontList, gFontSizeList, gFontStyleList;
  421.     if (pCurrentFontRecord[1] = "")
  422.     begin
  423.         ### Font assignment ####
  424.         whichFont := Random(1,Card(gFontList));                    # Random font position
  425.         currentFont := gFontList[whichFont];                    # Assign font from random position in list
  426.          # Replace old font with new
  427.         pCurrentFontRecord := ReplaceFont(currentFont,pCurrentFontRecord);
  428.     end;
  429.     if (pCurrentFontRecord[2] = "")
  430.     begin
  431.         ### Size assignment ####
  432.         whichSize := Random(1,Card(gFontSizeList));                # Random size position
  433.         currentSize := gFontSizeList[whichSize];                # Assign size from random position in list
  434.          # Replace old size with new
  435.          pCurrentFontRecord := ReplaceFontSize(currentSize,pCurrentFontRecord);
  436.     end;
  437.     if (pCurrentFontRecord[3] = "")
  438.     begin
  439.         if (gFontStyleList)        # Insure that gFontStyleList is defined
  440.         begin
  441.             ### Style assignment ####
  442.             availStyleList := gFontStyleList;                        # Assign global gFontStyleList to a temp value
  443.             styleList := {};                                        # Init the styleList
  444.             for numStyle := 1 to (Random(1, Card(availStyleList)))    # Add random number of styles (from 1 to random numbr of styles avail)
  445.             begin
  446.                 RandNum := Random(1,Card availStyleList);            # Select a random style from list of available styles
  447.                 styleList := Insert(availStyleList[RandNum],(Card(StyleList)+1),StyleList);    #Insert the random style into the end of the current Style list
  448.                 availStyleList := Remove(RandNum,availStyleList);        # Remove the Style from available Styles
  449.             end;
  450.             # Replace old StyleList with new
  451.             pCurrentFontRecord := ReplaceFontStyle(StyleList,pCurrentFontRecord);
  452.         end;
  453.     end;
  454.     return( pCurrentFontRecord );    
  455. end; # RandomFontRecords()
  456.  
  457.  
  458. #########################################################################
  459. #                        WaterFallFontTest()
  460. #========================================================================
  461. # Author:        KTA
  462. # Description:    Creates and executes font records based on the globals: gFontList,
  463. #                gFontSizeList, gFontStyleList. For each Font, each defined size will 
  464. #                be selected, with each of the defined styles. 
  465. # Parameters:    None
  466. # Returns:        nada
  467. # Examples:        WaterFallFontTest();
  468. # Assumptions:    global gPlainStyle is defined as the Plain style menu item
  469. #========================================================================
  470. # History:
  471. #
  472. #########################################################################
  473. TASK WaterFallFontTest() 
  474. begin
  475.     global gFontList, gFontSizeList, gFontStyleList,gPlainStyle,gCurrFontMenu,gCurrStyleMenu,
  476.     gCurrSizeMenu,gNextLineMethod,gNextLineClearsFontSettings, gFontObject;
  477.     styleList := {};                                    # Init styleList
  478.     currentFontRecord := {"","",""};                    # Init currentFontRecord
  479.     resetPlainFlag := 1;                                # Init resetPlainFlag
  480.     if (gNextLineClearsFontSettings)                    # Does method of moving to the next line clear the font settings
  481.     begin
  482.         completeRecord := 1;                            # If it does we need a complete record
  483.         resetPlainFlag := 0;                            # we also don't need to reset the styles to plain
  484.     end;
  485.     ### Font assignment ####
  486.     for each currentFont in gFontList                     # Do this for all the fonts in global gFontList.
  487.     begin
  488.         gFontObject := gFontObject + 1;  # Increment the object number for TCS info
  489.         currentFontRecord := ReplaceFont(currentFont,currentFontRecord); # Place current font into current fontRecord
  490.         continueFlag := 1;
  491.         ### Size assignment ####
  492.         for each currentSize in gFontSizeList             # Do this for each size in global gFontSizeList
  493.         begin
  494.             if (continueFlag)
  495.             begin
  496.                 currentFontRecord := ReplaceFontSize(currentSize,currentFontRecord); # Place current size into current fontRecord
  497.                 if(resetPlainFlag)    and (gPlainStyle)        # Do we want to reset the styles to plain between style selection
  498.                     Call (global gSetStyle, gPlainStyle,gFontObject);
  499.                 ### Style assignment ####        
  500.                 styleList := {};                            # ReInit styleList because we have a new size to deal with
  501.                 if (Card(gFontStyleList) > 0)                # gFontStyleList needs to contain items
  502.                 begin
  503.                     for each currentStyle in gFontStyleList     # Do this for all style defined in global gFontStyleList
  504.                     begin
  505.                         if (continueFlag)
  506.                         begin
  507.                             if not(completeRecord)            # if we move to a random location and click all styles will be cleared so we want to have a complete list
  508.                                 styleList := {};                    # ReInit Stylelist because previous style will still be selected
  509.                             styleList := insert(currentStyle,(Card(StyleList)+1),styleList);        # Build current styleList
  510.             
  511.                             currentFontRecord := ReplaceFontStyle(StyleList, currentFontRecord);     # Place current styleList into current fontRecord
  512.                                     FontRecord := SetFontParams(currentFontRecord,0,gFontObject);
  513.                                     If(FontRecord)
  514.                                     begin
  515.                                         ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject);    # Match and report back what is actually selected
  516.                                         Println "• - ",FontRecord;
  517.                                     end;
  518.                                     else
  519.                                     begin
  520.                                         Println "NOTE: Couldn't complete FontRecord • - ", currentFontRecord;
  521.                                         continueFlag := 0;
  522.                                     end;
  523.                             if not(completeRecord)                        # If we don't need a complete record
  524.                                 currentFontRecord := {"","",""};        # Reinitialize so were only passing a Style and not a complet record
  525.                         end;
  526.                     end;
  527.                 end;
  528.                 else    # Handle an empty gFontStyleList
  529.                 begin
  530.                     FontRecord := SetFontParams(currentFontRecord,0,gFontObject);
  531.                     ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu},gFontObject);    # Match and report back what is actually selected
  532.                     Println "• - ",FontRecord;
  533.                 end;
  534.             end;
  535.         end;
  536.     end;
  537. end; # WaterFallFontTest()
  538. (*
  539. #########################################################################
  540. #                        QuickLookTextTest()
  541. #========================================================================
  542. # Author:        KTA
  543. # Description:    Creates and executes font records based on the globals: gFontList,
  544. #                gFontSizeList, gFontStyleList. For each Font will select 
  545. #                random size and random number of styles.
  546. # Parameters:    none
  547. # Returns:        nada
  548. # Examples:        QuickLookTextTest();
  549. # Assumptions:    global gPlainStyle is defined as the Plain style menu item
  550. #========================================================================
  551. # History:
  552. #
  553. #########################################################################
  554. TASK QuickLookTextTest() 
  555. begin
  556.     global gFontList, gFontSizeList, gFontStyleList,gCurrStyleMenu,gNextLineMethod;
  557.     styleList := {};                                    # Init styleList
  558.     currentFontRecord := {"","",""};                    # Init currentFontRecord
  559.     ### Font assignment ####
  560.     for each currentFont in gFontList                     # Do this for all the fonts in global gFontList.
  561.     begin
  562.         currentFontRecord := ReplaceFont(currentFont,currentFontRecord); # Place current font into current fontRecord
  563.         
  564.         ### Size assignment ####
  565.         whichSize := Random(1,(Card gFontSizeList));            # Random Size
  566.         currentSize := gFontSizeList[whichSize];
  567.             currentFontRecord := ReplaceFontSize(currentSize,currentFontRecord); # Place current size into current fontRecord
  568.  
  569.         ### Style assignment ####
  570.         availStyleList := gFontStyleList;                        # Assign global gFontStyleList to a temp value
  571.         styleList := {};                                        # Init the styleList
  572.         for numStyle := 1 to (Random(1, Card(availStyleList)))    # Add random number of styles (from 1 to random numbr of styles avail)
  573.         begin
  574.             RandNum := Random(1,Card availStyleList);            # Select a random style from list of available styles
  575.             styleList := Insert(availStyleList[RandNum],(Card(StyleList)+1),StyleList);    #Insert the random style into the end of the current Style list
  576.             availStyleList := Remove(RandNum,availStyleList);        # Remove the Style from available Styles
  577.         end;
  578.         # Replace old StyleList with new
  579.         currentFontRecord := ReplaceFontStyle(StyleList,currentFontRecord);
  580.         println "The current font record is: ",currentFontRecord;
  581.         SetFontParams(currentFontRecord);
  582.     end;
  583. end; # QuickLookTextTest()
  584. *)
  585. #########################################################################
  586. #                        SetFontParams(pFontRecord, pResetPlainFlag, pObjectNumber)
  587. #========================================================================
  588. # Author:        KTA
  589. # Description:    Executes font records bycalling the routines necessary for  selecting 
  590. #                the font (pFontRecord[1]) if its defined, selecting the size 
  591. #                (pFontRecord[2]) if its defined, then selecting each style defined
  592. #                in the styleRecord (pFontRecord[3]). ReportSelectedMenuItems is then
  593. #                called to report all of the menu items in the appropriate menus 
  594. #                with a MarkChar.
  595. # Parameters:    pFontRecord- {Font,Size,{Style1,Style2}}
  596. #                pResetPlainFlag - 
  597. #                    1 - Select <gPlainStyle> before executing the StyleRecord
  598. #                     loop so styles will begin at a cleared state.
  599. #                    0 - Won't select the plain menu item.
  600. #                pObjectNumber - Integer used to track all elements that make up 
  601. #                                an Font record - TCS related.
  602. # Returns:        By default,  returns what SetStyle returns 
  603. # Examples:        SetFontParams();
  604. # Assumptions:    global gPlainStyle is defined as the Plain style menu item
  605. #========================================================================
  606. # History:
  607. #
  608. #########################################################################
  609. TASK SetFontParams(pFontRecord,pResetPlainFlag := 1, pObjectNumber)
  610. begin
  611.     returnVal := 0;
  612.     #Println "• - pFontRecord is: ",pFontRecord;
  613.     global gPlainStyle;        # Init globals
  614.     if (pFontRecord[1])                                       # If we passed in a Font
  615.         returnVal:= call (global gSetFont, pFontRecord[1],pObjectNumber);            # Set the Font
  616.     if not(pFontRecord[1])    or ((pFontRecord[1]) and (returnVal))    # don't want to continue if font selection failed.
  617.     begin
  618.         if (pFontRecord[2])                                # If we passed in a Size
  619.             returnVal := call (global gSetSize, pFontRecord[2],pObjectNumber);        # Set the Size
  620.     
  621.         if (pResetPlainFlag) and (gPlainStyle)
  622.             returnVal := call (global gSetStyle, gPlainStyle,pObjectNumber);            # Reset to plain
  623.     
  624.         styleRecord := pFontRecord[3];                    # Define the StyleRecord
  625.         if(styleRecord)
  626.         begin
  627.             for each currentStyle in styleRecord             # For all the Styles
  628.                 returnVal := call (global gSetStyle, currentStyle,pObjectNumber);    # Set the Style
  629.         end;
  630.     end;
  631.     if(returnVal)
  632.         returnVal := pFontRecord;
  633.     return(returnVal);
  634. end; # SetFontParams()
  635.             
  636. #########################################################################
  637. #                        ReportSelectedMenuItems(pMenuList, pObjectNumber)
  638. #========================================================================
  639. # Author:        KTA
  640. # Description:    Collects all the menu items with a markChar ('') from the 
  641. #                defined menus defined in pMenuList. Then types each marked item 
  642. #                and calls NextLine() to move to the next text entry line.
  643. # Parameters:    pMenuList - List of lists/strings 
  644. #                    List of menus containing marked menuitems. 
  645. #                pObjectNumber - Integer used to track all elements that make up 
  646. #                                an Font record - TCS related.
  647. # Returns:        nada
  648. # Examples:        ReportSelectedMenuItems({{'Format','Font'},{'Format','Styles'});
  649. # Assumptions:    
  650. #========================================================================
  651. # History:
  652. # KTA    7/8/93    Check to see if duplicate items in pMenuList
  653. # KTA    8/24/93    TCS stack parity check
  654. # KTA    9/21/93    Removed gHandleTextEntry
  655. #########################################################################
  656. TASK ReportSelectedMenuItems(pMenuList, pObjectNumber) 
  657. begin
  658.     if global gReportSelectedMenuItems
  659.         call (gReportSelectedMenuItems);
  660.     else # if no custom Task for reporting selected
  661.     begin
  662.         failStr := '';
  663.         markChar := '';                                # MARK CHAR
  664.         selectedItems := "";                            # Init selectedItems
  665.         
  666.         ##Check to see if duplicate items in pMenuList
  667.         tempMenuList := {};
  668.         for each menuRec in pMenuList
  669.         begin
  670.             if not(isMember(menuRec, tempMenuList))
  671.                 tempMenuList := Insert(menuRec, Card(tempMenuList)+1, tempMenuList);
  672.         end;
  673.         pMenuList := tempMenuList;
  674.         
  675.         for each menuRecord in pMenuList 
  676.         begin
  677.             currentMenu := 0;                            # reinitialize the currentmenu
  678.             if not(TypeOf(menuRecord) = 'list')        # Single menu item
  679.                 currentMenu := menuRecord;
  680.             else if not(menuRecord[2])                # Menu is not hierarchical
  681.                 currentMenu := menuRecord[1];
  682.             else                                         # Menu is hierarchical
  683.                 activeList := collect[menuItem c:markChar m:[menuitem t:menuRecord[1] m:[menu t:menuRecord[2]]]]!;
  684.     
  685.             if(currentMenu)
  686.                 activeList := collect[menuItem c:markChar m:[menu t:currentMenu]]!;
  687.             for each style in activeList 
  688.             begin
  689.                 selectedMenuItem := style.t;
  690.                 selectedItems := "{selectedItems}-{selectedMenuItem}";        # Build the list of selected menu items
  691.             end;
  692.         end;
  693.         TCSStart({ 4, global kTCSetFont },"Type SelectedItems String");                # Start TCS
  694.         
  695.         if(selectedItems)
  696.         begin
  697.             TypeStr(selectedItems);                            # Type the selected menu items
  698.             TCSFlag := 1;                                    # Pass the TCS
  699.         end;
  700.         else
  701.             TCSFlag := 0;                                    # Fail the TCS
  702.         
  703.         DialogReturn := DialogCheck("",1);                # Check to see if a dialog appeared
  704.         if (DialogReturn)
  705.         begin
  706.             TCSFlag := 0;                                # Fail the TCS
  707.             failStr := DialogReturn;                    # Set failStr to the string DialogCheck() returns
  708.         end;
  709.         TCSEnd({ 4, global kTCSetFont }, TCSFlag, failStr,pObjectNumber);
  710.     end; # if no custom Task for reporting selected
  711.     call (global gNextLine);                                        # Move to the next line
  712. end; # ReportSelectedMenuItems()
  713.